<template>
  <div class="live-picture app-wrapper">
    <VideoPlayer></VideoPlayer>
    <div class="live-picture-main">
      <div class="live-summary">
        <h3 class="live-summary-title">第二届世界互联网大会</h3>
        <p class="live-summary-other clearfix">239次浏览<a href="#" class="pull-right" @click.prevent="showDetailPanel = true">活动详情 ></a></p>
      </div>

      <div class="style-option-bar clearfix">
        <div class="tab-header pull-left">
          <div class="tab-header-item active">全部(235)</div>
          <div class="tab-header-item">时间轴</div>
        </div>
        <p class="show-style pull-right">
          <span class="item active"><i class="icon icon-sort"></i></span>
          <span class="item"><i class="icon icon-grid9"></i></span>
          <span class="item"><i class="icon icon-four-case"></i></span>
          <span class="item"><i class="icon icon-two-case"></i></span>
        </p>
      </div>
      <div class="live-picture-wrapper">
        <p class="time time-year">2019-07-12</p>
        <p class="time time-second">13:20-15:30</p>
        <div class="live-picture-list" style="display: none;">
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
        </div>
        <div class="live-picture-list double clearfix" style="display: none;">
          <div class="live-picture-item" 
            v-for="item in imgList"
            :key="item.id"
          >
            <img :src="item.src" alt="">
            <span class="button-circle"
              :class="{'active': item.checked}"
              @click.stop="checkedCircle(item)"
            >
            </span>
          </div>
          <!-- <div class="live-picture-item">
            <img src="./img/live_main.jpg" alt="">
            <span class="button-circle" @click="checkedItem"></span>
          </div> -->
        </div>
        <div class="live-picture-list three clearfix">
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
          <div class="live-picture-item"><img src="./img/live_main.jpg" alt=""></div>
        </div>
      </div>
    </div>



    <div class="option-bar">
      <div class="option-bar-item">
        <i class="icon icon-seek"></i><p>找我</p>
      </div>
      <div class="option-bar-item">
        <i class="icon icon-puzzle"></i><p>拼图</p>
      </div>
      <div class="option-bar-item">
        <i class="icon icon-carousel"></i><p>轮播</p>
      </div>
      <div class="option-bar-item">
        <i class="icon icon-share-3"></i><p>分享</p>
      </div>
    </div>


    <div class="popup-panel"
      :class="{'show': showDetailPanel}"
    >
      <a href="#" class="popup-panel-close" @click.prevent="showDetailPanel = false">×</a>
      <p>直播名称：第二届世界互联网大会</p>
      <p>开始时间：2019-07-12 13:30</p>
      <div class="report">举报反馈</div>
    </div>
    <!-- /活动详情 -->

    <div class="piecing-bar" 
      :class="{'show': showPiecingBar}"
    >
      <div class="piecing-baitem"><button class="button" @click="cancelPiecing">退出拼图</button></div>
      <div class="piecing-baitem"><span class="counts">拼图({{selectedNums}}/{{imgList.length}})</span></div>
    </div>

    <PiecingPage></PiecingPage>
  </div>
</template>

<script>
import VideoPlayer from '@/components/Live/VideoPlayer2.vue';
import PiecingPage from './Piecing.vue';

let imgUrl = require('./img/live_main.jpg');
export default {
  components: {
    VideoPlayer,
    PiecingPage
  },
  props: {},
  data() {
    return {
      showDetailPanel: false,
      showPiecingBar: false,
      selectedNums: 0,
      imgList: [
        {
          id: 1,
          src: imgUrl,
          checked: false
        },
        {
          id: 2,
          src: imgUrl,
          checked: false
        },
        {
          id: 3,
          src: imgUrl,
          checked: false
        },
        {
          id: 4,
          src: imgUrl,
          checked: false
        }
      ]
    };
  },
  // computed: {
  //   selectedNums(){
  //     return this.imgList.filter((item)=>item.checked).length;
  //   }
  // },
  methods: {
    checkedCircle(item){
      item.checked = !item.checked;
      this.selectedNums = this.imgList.filter((item)=>item.checked).length;
    },
    cancelPiecing(){
      this.imgList.forEach((item)=>{
        item.checked = false;
      });

      this.selectedNums = 0;
    }
  },
  created() {},
  mounted() {},
  watch: {
    selectedNums(){
      this.showPiecingBar = this.selectedNums > 0;
    }
  }
};
</script>
<style lang="scss" scoped>
@import '@/assets/config.scss';

.live-picture-main {
  height: calc(100% - 350px);
  padding: 0 35px;
  background-color: #fff;
}

.live-summary {
  padding: 16px 0;
  border-bottom: 1px solid #f0f0f0;
}

.live-summary-title {
  font-size: 34px;
  color: #000;
}

.live-summary-other {
  font-size: 24px;
  line-height: 2;
  color: #999;
  > a{
    color: $blue;
  }
}


.style-option-bar {
  line-height: 90px;
  .tab-header-item {
    float: left;
    margin-right: 90px;
    font-size: 30px;
    color: #333;
    
    &.active{
      position: relative;
      color: $blue;
      &:after{
        position: absolute;
        content: '';
        width: 100%;
        height: 4px;
        background-color: $blue;
        bottom: 0;
        left: 0;
      }
    }
  }

  .show-style {
    font-size: 0;
    .item {
      display: inline-block;
      width: 40px;
      height: 40px;
      margin-left: 30px;
      font-size: 36px;
      line-height: 40px;
      vertical-align: middle;
      &.active { color: $blue; }
      &:first-child { margin-left: 0; }
    }
  }
}

.live-picture-wrapper {
  padding-top: 20px;
  overflow-x: hidden; 
  > .time { line-height: 1.5; }
  .time-year { 
    font-size: 30px;
    color: #333;
  }

  .time-second {
    font-size: 24px;
    color:#999;
  }
}

.live-picture-list {
  padding-top: 10px;
  img { max-width: 100%;}
  .live-picture-item { position: relative; }
  .button-circle {
    width: 36px;
    height: 36px;
    border: 1px solid #fff;
    background: rgba(255,255,255,.7);
    position: absolute;
    top: 16px;
    right: 16px;
    border-radius: 100%;
  }
  &.double {
    .live-picture-item {
      float: left;
      width: 50%;
      margin-bottom: 4px;
      &:first-child,&:nth-of-type(3n){ padding-right: 2px; }
      &:nth-of-type(2n){ padding-left: 2px; }
    }
  }

  &.three {
    .live-picture-item {
      float: left;
      width: calc(100% / 3);
      margin-bottom: 4px;
      padding: 0 2px;
      // &:first-child,&:nth-of-type(3n){  }
      // &:nth-of-type(3n){ padding-left: 2px; }
    }
  }
}

.option-bar {
  position: fixed;
  right: 35px;
  bottom: 24px;
  font-size: 24px;
  color:#fff;
  .icon {
    display: inline-block;
    margin-top: 6px;
    font-size: 42px;
  }
  .option-bar-item {
    width: 94px;
    height: 94px;
    margin-bottom: 24px;
    
    text-align: center;
    border-radius: 100%;
    background-color: rgba(21, 73, 235, .7);
    p {
      font-size: 24px;
    }
  }
}


.popup-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 495px;
  padding: 60px 35px 40px;
  background-color: #fff;
  line-height: 2;
  transition: all ease-in-out .3s;
  transform: translate3d(0, 100%, 0);
  &.show {
    transform: translate3d(0, 0, 0);
  }

  .popup-panel-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 64px;
    color: #666;
    line-height: 1;
  }

  p {
    font-size: 30px;
    color: #000;
  }

  .report {
    font-size: 28px;
    color: $blue;
    position: absolute;
    left: 50%;
    bottom: 40px;
    transform: translate(-50%, 0);
  }
}

.piecing-bar {
  display: flex;
  width: 100%;
  padding: 16px 0 14px;
  border-top: 1px solid #f0f0f0;
  position: fixed;
  left: 0;
  bottom: 0;
  background: #fff;
  transition: all ease-in-out .15s;
  transform: translate3d(0, 100%, 0);
  &.show {
    transform: translate3d(0, 0, 0);
  }

  >.piecing-baitem {
    flex: 1;
    text-align: center;
    font-size: 0;
  }

  .button, .counts {
    display: inline-block;
    width: 268px;
    height: 80px;
    font-size: 32px;
    line-height: 80px;
    border-radius: 40px;
  }

  .button {
    color: #a1710d;
    background-color: $color-orange;
  }

  .counts {
    color: #666;
    background-color: #ccc;
  }
}
</style>